<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>后台</title>
        <link rel="stylesheet" type="text/css" href="/static/js/jquery/easyui/themes/default/easyui.css">
        <link rel="stylesheet" type="text/css" href="/static/js/jquery/easyui/themes/icon.css">    
        <script type="text/javascript" src="/static/js/jquery/easyui/jquery.min.js"></script>
        <script type="text/javascript" src="/static/js/jquery/easyui/jquery.easyui.min.js"></script>
        <script type="text/javascript" src="/static/js/jquery/easyui/locale/easyui-lang-zh_CN.js"></script>
        <script type="text/javascript">
            $('#main_content').tabs({
                onLoad:function(panel){
                    var plugin = panel.panel('options').title;
                    dp.SyntaxHighlighter.ClipboardSwf = '/SyntaxHighlighter/Scripts/clipboard.swf';
                    dp.SyntaxHighlighter.HighlightAll('code-' + plugin);
                }
            });
            
            function addTab(name,url){
                var options = {
                    title:name,
                    content:'<iframe scrolling="auto" frameborder="0" style="width:100%;height:99%" src="'+url+'"></iframe>',
                    closable:true
                };
                if ($('#main_content').tabs('exists',name)){
                    $('#main_content').tabs('select', name);
                    //                    var tab = $("#main_content").tabs('getSelected');       
                    //                    $("#main_content").tabs('update',{  
                    //                        tab:tab, 
                    //                        options:options
                    //                    });
                } else {
                    $('#main_content').tabs('add',options);
                }
            }
            
            // 刷新左边菜单列表
            function menuTreeReload(){
                $('#memuTree').tree('reload');
            }
            $(function(){
                $('#memuTree').tree({
                    url:"index.php?action=getdata",
                    onClick:function(node){
                        if(node.attributes.url != ''){
                            addTab(node.text,node.attributes.url);
                        }
                    }
                    
                });
            })
            
            $(function(){

                /*为选项卡绑定右键*/
                $(".tabs li").live('contextmenu',function(e){
        
                    /* 选中当前触发事件的选项卡 */
                    var subtitle =$(this).text();
                    $('#main_content').tabs('select',subtitle);
        
                    //显示快捷菜单
                    $('#menu').menu('show', {
                        left: e.pageX,
                        top: e.pageY
                    });
        
                    return false;
                });
                
                //刷新当前标签
                $("#m-refresh").click(function(){
                    var currTab = $('#main_content').tabs('getSelected');    //获取选中的标签项
                    var url = $(currTab.panel('options').content).attr('src');    //获取该选项卡中内容标签（iframe）的 src 属性
                    var title = currTab.panel('options').title;    //获取该选项卡中内容标签（iframe）的 src 属性
                    /* 重新设置该标签 */
                    $('#main_content').tabs('update',{
                        tab:currTab,
                        options:{
                            title:title,
                            content:'<iframe scrolling="auto" frameborder="0" style="width:100%;height:99%" src="'+url+'"></iframe>',
                        }
                    })
                });
    
                //关闭所有标签
                $("#m-closeall").click(function(){
                    $(".tabs li").each(function(i, n){
                        var title = $(n).text();
                        if(title !='首页'){
                            $('#main_content').tabs('close',title);    
                        }
                    });
                });
    
                //关闭其它标签
                $("#m-closeother").click(function(){
                    var currTab = $('#main_content').tabs('getSelected');
                    currTitle = currTab.panel('options').title;    
        
                    $(".tabs li").each(function(i, n){
                        var title = $(n).text();
            
                        if(currTitle != title && title !='首页'){
                            $('#main_content').tabs('close',title);            
                        }
                    });
                });
    
                //关闭当前标签
                $("#m-close").click(function(){
                    var currTab = $('#main_content').tabs('getSelected');
                    currTitle = currTab.panel('options').title;    
                    $('#main_content').tabs('close', currTitle);
                });
            });
        </script>
    </head>
    <body class="easyui-layout">
        <div data-options="region:'north',split:true"  style="height:50px;padding:2px;">
            <p style="float:right;"> <strong>账户名:</strong> {{$smarty.session.adminUserInfo.admin_name}} <strong>角色:</strong> {{$smarty.session.adminUserInfo.user_group_name}} <a href="login.php?action=logout">安全退出</a></p>
        </div>

        <div data-options="region:'west',iconCls:'icon-reload',split:true" title="菜单" style="width:180px;">
            <ul id="memuTree"></ul>
        </div>

        <div data-options="region:'center',height:'auto'" title="" style="overflow:hidden;">
            <div id="main_content" class="easyui-tabs" data-options="fit:true,border:false">
                <div title="首页" data-options="closable:true,content:'<iframe scrolling=\'auto\' frameborder=\'0\' style=\'width:100%;height:99%\' src=\'index.php?action=report\'></iframe>'"  style="overflow:hidden;padding:5px;">
                    	
                </div>
            </div>
        </div>

        <div id="menu" class="easyui-menu" style="width:150px;">
            <div id="m-refresh">刷新</div>
            <div class="menu-sep"></div>
            <div id="m-closeall">全部关闭</div>
            <div id="m-closeother">关闭其它</div>
            <div class="menu-sep"></div>
            <div id="m-close">关闭</div>
        </div>
    </body>
</html>